package com.apobates.jforum2.troll.replies.mapper;

import com.apobates.jforum2.troll.replies.entity.MoodCollectResult;
import com.apobates.jforum2.troll.replies.stub.vo.ReplyMoodVo;
import com.apobates.jforum2.troll.utils.core.api.OptionalEntityTransformMapper;
import java.util.Optional;
import java.util.function.Function;

/**
 *
 * @author xiaofanku
 */
public class ReplyMoodVoMapperEntity implements OptionalEntityTransformMapper<MoodCollectResult, ReplyMoodVo>{
    @Override
    public Optional<ReplyMoodVo> transform(Optional<MoodCollectResult> entity) {
        return entity.map(ins->{
            return mapper().apply(ins);
        });
    }

    public static Function<MoodCollectResult, ReplyMoodVo> mapper(){
        return (MoodCollectResult mcr)->{
            ReplyMoodVo rmv = new ReplyMoodVo();
            rmv.setThreads(mcr.getTopic());
            rmv.setReply(mcr.getPosts());
            rmv.setLikes(mcr.getLikes());
            rmv.setHates(mcr.getHates());
            return rmv;
        };
    }
}